package com.javakademi.tag.elements;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *
 * @author Bora SAYINER
 * @since Jan 14, 2015 11:35:18 PM
 * @version 1.0
 */
public class MenuItemTag extends SimpleTagSupport {

	private String link;
	private String label;
	private boolean active;

	public MenuItemTag() {
		setActive(false);
	}

	@Override
	public void doTag() throws JspException, IOException {
		if (active) {
			getJspContext().getOut().print(String.format("<li class='pure-menu-selected'><a href='%s'>%s</a></li>", link, label));
		} else {
			getJspContext().getOut().print(String.format("<li><a href='%s'>%s</a></li>", link, label));
		}
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}
}
